package com.imooc.product.client;

import com.imooc.product.common.DecreaseStockInput;
import com.imooc.product.common.ProductInfoOutput;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

import java.util.List;

/**
 * @author : 浦希成
 * @date : 2018/7/30 13:54
 */

@FeignClient(name = "product",fallback = ProductClient.ProductClientFallback.class )
@Component
public interface ProductClient {

    @PostMapping("/product/listForOrder")
    List<ProductInfoOutput> listForOrder(List<String> productIdList);
    @PostMapping("product/decreaseStock")
    void decreateStock(List<DecreaseStockInput> cartDTOList);

    @Component
    static class ProductClientFallback implements ProductClient{

        @Override
        public List<ProductInfoOutput> listForOrder(List<String> productIdList) {
            return null;
        }

        @Override
        public void decreateStock(List<DecreaseStockInput> cartDTOList) {

        }
    }
}